package questionanswer;

import java.io.Serializable;

/**
 * Presents a testQuestion with answersArray
 */
public class Question implements Serializable {
    private String testQuestion;
    private Answer answer;
    private String theme;

    public Question(String question, Answer answer, String theme) {
        this.testQuestion = question;
        this.answer = answer;
        this.theme = theme;
    }

    /**
     * creates new identical<code>Question</code> object from original
     */
    public Question(Question original) {
        this.testQuestion = original.testQuestion;
        this.answer = AnswerCopyFactory.createNewAnswer(original.answer);
    }

    public boolean isEqualsQuestions(Question someQuestion) {
        return (this.testQuestion.equals(someQuestion.testQuestion));
    }

    public boolean isCorrect(String userAnswer) {
        return answer.isCorrect(userAnswer);
    }

    public String getTheme () {
        return theme;
    }

    public void shuffleAnswers() {
        answer.shuffleAnswers();
    }

    @Override
    public String toString() {
        return String.format("%s%n%s", testQuestion, answer);
    }
}
